<?php
// 友情链接的提交申请

include '../../init.php';

$name    = $_POST['name'];
$sitename= $_POST['sitename'];
$phone   = $_POST['phone'];
$flink   = $_POST['flink'];
$netlogo = $_POST['netlogo'];
$logo    = $_FILES['logo'];

if (empty($name)|| empty($phone) || empty($flink) || empty($sitename)){
	show_msg(1, '必填数据不能为空');
	exit();
}


// 上传图片处理
$info = ['insertid'=>0];
if ($logo['error'] != 4){
    $info = execute_file($logo, false);
    if ($info === false){
        show_msg(1, '上传logo错误');
        exit();
    }
}

$data_list = array();
$logoid = $info['insertid'];
$sql  = "INSERT INTO `flink_tb`(lid, flink, name, sitename, phone, logo, netlogo, apply_time) ";
$sql .= "values(null, '{$flink}', '{$name}', '{$sitename}', '{$phone}', {$logoid}, '{$netlogo}', ".time().") ;";
if (!my_mysql_query($sql, $data_list)){
	show_msg(1, '上传logo插入数据库错误');
	exit();
}

show_msg(0, '申请友情链接成功', 2, '../../index.php');

?>